package service.impl;

import java.util.List;
import model.IRoutsStantion;
import persistence.dao.DaoManager;
import persistence.dao.RoutsStantionDao;
import persistence.dao.base.ConnectionBehavior;
import persistence.dao.base.DaoCommand;
import service.RoutsStantionService;

public class RoutsStantionServiceImpl implements RoutsStantionService {

	private DaoManager daoManager;

	public RoutsStantionServiceImpl(DaoManager daoManager) {
		this.daoManager = daoManager;
	}

	protected DaoManager getDaoManager() {
		return daoManager;
	}

	@Override
	public List<IRoutsStantion> getRoutsStantion() {
		return null;
	}

	@Override
	public IRoutsStantion deleteOrder(final int[] id_check_routs) {
		return (IRoutsStantion) getDaoManager().command(new DaoCommand() {
			public Object execute(final DaoManager manager) {
				final RoutsStantionDao routsStantionDao = manager.getDao(RoutsStantionDao.class);
				routsStantionDao.deleteOrder(id_check_routs);
				return null; 
			}
		}, ConnectionBehavior.CLOSE);
	}

	@Override
	public IRoutsStantion delete(final int[] id_stantion_city) {
		return (IRoutsStantion) getDaoManager().command(new DaoCommand() {
			public Object execute(final DaoManager manager) {
				final RoutsStantionDao routsStantionDao = manager.getDao(RoutsStantionDao.class);
				routsStantionDao.delete(id_stantion_city);
				return null;
			}
		}, ConnectionBehavior.CLOSE);
	}

	@Override
	public IRoutsStantion setRoutsStantion(final int[] id_city,
			final int id_routs) {
		return (IRoutsStantion) getDaoManager().command(new DaoCommand() {
			public Object execute(final DaoManager manager) {
				final RoutsStantionDao routsStantionDao = manager.getDao(RoutsStantionDao.class);
				routsStantionDao.setRoutsStantion(id_city, id_routs);
				return null; 
			}
		}, ConnectionBehavior.CLOSE);
	}

}
